var member;
$(function(){
	member=getEntity("memberInfo");
	var redirect = GetQueryString("redirect");
/*var member;
$(function(){
	//member=getEntity("memberInfo");
	//var type=$("#type").val();
	var redirect = GetQueryString("redirect");
	$.ajax({
		type:"post",
		url:rootPath+"/advert/getAdvertList",
		data:{'amount':6,'type':type},
		//dataType:"json",
		success:function(data){
			if(data.resultSuccess){
				var adverts=data.data;
				var str='';
				$.each(adverts,function(i,item){
					str+='<img src="'+item.img+'" alt="1"/>'
				})
				$("#list").empty();
				$("#list").append(str);
			}
		}
	})*/
	$("#loginbtn").click(function(){
		var data = $("form").serialize();
		//alert(123);
		$.ajax({
			type:"post",
			url:rootPath+"/member/login",
			data:data,
			//dataType:"json",
			success:function(data){
				if(data.resultSuccess){
					$("#msg").text("");
					//alert(data.resultDesc)
					if(""==redirect){
						window.location.href=rootPath+"/";
					}else{
						window.location.href=rootPath + redirect;
					}
				}else{
					$("#msg").text(data.resultDesc)
					$("#msg").css("font-size","28px")
					.css("text-align","center")
					.css("margin-top","66px")
					.css("margin-bottom","-50px")
					.css("color","red");
				}
			}
		})
	})
	if(member){
		//$("a:contains('登录'),a:contains('注册')").hide();
		$(".nav .r").prepend("<a href='' class='me'>"+member.mName+"</a>");
		$(".me").append("<ul><li id='memberInfo'>个人中心</li><li id='exit'>退出</li></ul>");
	}
	$(document).on('mouseover mouseout','.me',function(e){
		if(e.type == "mouseover"){
			$(this).find('ul').stop().slideDown();
			$(this).css('position','relative');
			$(this).find('ul').css('display','inline-block');
			$(this).find('ul').css('padding','5px')
			.css('position','absolute')
			.css('width','100px')
			.css('top','28px')
			.css('left','-8px')
			.css('color','#000')
			.css('padding','5px');
			$(this).find('li').css('margin','0')
			.css('line-height','20px')
			.css('text-align','center');
		}else if(e.type == "mouseout"){
			$(this).find('ul').stop().slideUp();
		}
	});
	$(document).on('click','#memberInfo',function(e){
		$.ajax({
			type:"post",
			url:rootPath+"/member/skip",
			//dataType:"json",
			success:function(data){
				if(data.resultSuccess){
					window.location.href=rootPath+"/member/vip_safe_setting";
				}
			}
		})
	})
	$(document).on('click','#exit',function(e){
		$.ajax({
			type:"post",
			url:rootPath+"/member/exit",
			//dataType:"json",
			success:function(data){
				if(data.resultSuccess){
					window.location.href=rootPath+"/member/loginPre";
				}
			}
		})
	})

})